﻿using System;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Prospectus
{
    public enum BlockType
    {
        Passable = 0,
        Impassable = 1,
        Platform = 2,
        Finish = 3,
    }

    public enum BlockMaterial
    {
        Coal = 0,
        Dirt = 1,
        Iron = 2,
        Plutonium = 3,
        Rock = 4,
        Silver = 5,
        Uranium = 6,
        Empty = 7,
    }

    public class Block
    {
        public Texture2D Texture;

        public BlockType BlockType;
        public BlockMaterial BlockMaterial = BlockMaterial.Empty;

        public float Strength;

        public static readonly Vector2 Size = new Vector2(Engine.BlockWidth, Engine.BlockHeight);

        public string Name
        {
            get { return name; }
            private set { name = value; }
        }
        private string name;

        public Vector2 Origin
        {
            get { return new Vector2(0, 0); }
            set { origin = value; }
        }
        private Vector2 origin;

        public float Rotation
        {
            get { return rotation; }
            private set { rotation = value; }
        }
        private float rotation;

        public Rectangle SourceRectangle
        {
            get { return sourceRectangle; }
            private set { sourceRectangle = value; }
        }
        private Rectangle sourceRectangle;

        public char MapData
        {
            get { return mapData; }
            private set { mapData = value; }
        }
        private char mapData;

        private SpriteEffects effects;
        public SpriteEffects SpriteEffects
        {
            get { return effects; }
            set { effects = value; }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        public Block(Texture2D texture, BlockType blockType, char mapData)
        {
            Texture = texture;
            BlockType = blockType;
            MapData = mapData;

            name = String.Empty;
            BlockMaterial = BlockMaterial.Empty;
            Rotation = 0.0f;
            if (texture != null)
                SourceRectangle = new Rectangle(0, 0, Texture.Width, Texture.Height);
            Origin = Vector2.Zero;
            Strength = 0.0f;
        }

        /// <summary>
        /// Constructor for use with the Block Dictionary method
        /// </summary>
        public Block(Texture2D texture, String name, BlockMaterial blockMaterial, BlockType blockType, char mapData, float rotation, Rectangle sourceRectangle, Vector2 origin, float strength)
        {
            Texture = texture;
            Name = name;
            BlockMaterial = blockMaterial;
            BlockType = blockType;
            MapData = mapData;
            Rotation = rotation;
            SourceRectangle = sourceRectangle;
            Origin = origin;
            Strength = strength;

            effects = SpriteEffects.None;
        }
    }
}
